<?php
include 'includes.php';

function sufijoItem($item) {
    $dificultad = "";

    if ($item['Bis'] == 1) {
        if ($item['dificultad'] == 'H') {
            $dificultad = 'BIS H.png';
        } else {
            $dificultad = 'BIS.png';
        }
    } else {
        if ($item['dificultad'] == 'H') {
            $dificultad = 'H.png';
        } else {
            $dificultad = 'HW.png';
        }
    }

    return $dificultad;
}

if (isset($_GET['raid'])) {
    $id = $_GET['raid'];
} else {
    $id = 1;
}

$raids = R::getAll("select * from raid order by prioridad desc");


$bosses = R::getAll("select * from bosses where raid_id = :id", [':id' => $id]);


$playersTanke = R::getAll("select * from pjs where rol = 'Tanke' order by clase");
$playersHeal = R::getAll("select * from pjs where rol ='Heal' order by clase");
$playersDPSMelee = R::getAll("select * from pjs where rol ='DPS Melee' order by clase");
$playersDPSCaster = R::getAll("select * from pjs where rol ='DPS Caster' order by clase");
?>

<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="shortcut icon" href="../../assets/ico/favicon.ico">
        <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
        <link href="bootstrap/css/bootstrap.css" rel="stylesheet">
        <link href="bootstrap/css/css.css" rel="stylesheet">
        <script type="text/javascript" src="bootstrap/js/jquery-2.1.1.js"></script>
        <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
         <script type="text/javascript" >
             $(document).on('.tooltip.data-api');
             
         </script>

        <title>The Pengüins mafia Bis List</title>

    </head>


    <!-- Bootstrap core CSS -->



    <?php
    include './cabecera.php';
    ?>

    <!-- Main jumbotron for a primary marketing message or call to action -->
    <script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script><script>var wowhead_tooltips = {"colorlinks": true, "iconizelinks": false, "renamelinks": false}</script>
    <div class="container-fluid contenido">

        <ul class="nav nav-tabs">
            <?php
            foreach ($raids as $r) {
                if ($r['id'] == $id) {
                    $class = 'class="active"';
                } else {
                    $class = '';
                }
                echo '<li ' . $class . ' ><a href="index.php?raid=' . $r['id'] . '">' . $r['nombre'] . '</a></li>';
            }
            ?>
            <li class="list-group-item">Leyenda: <img class="imgicono" src="iconos/Anillo BIS.png" data-toggle="tooltip" data-original-title="BIS HW"><img class="imgicono" src="iconos/Anillo BIS H.png" data-toggle="tooltip" data-original-title="BIS H"><img class="imgicono" src="iconos/Anillo HW.png" data-toggle="tooltip" data-original-title="HW"><img  class="imgicono" src="iconos/Anillo H.png" data-toggle="tooltip" data-original-title="H"></li>
        </ul>
        
    </div>
    <br />
    <div class="DocumentList">

        <div class="row row1">
            <table class="tg">
                <tr>
                    <th class="DocumentItemD tipo"></th>
                    <th class="DocumentItemC tipoplayer">Players: <?php echo count($playersTanke) + count($playersDPSMelee) + count($playersHeal) + count($playersDPSCaster); ?></th>
                    <?php
                    foreach ($bosses as $b) {
                        echo "<th class='DocumentItemC'><a href='editarBisList.php?id=" . $b['id'] . "'>" . $b['nombre'] . "</a></th>";
                    }
                    ?>
                    <th class="DocumentItemC tipoplayer3">Players</th>
                </tr>
                <tr>
                    <td class="DocumentItemB tiporol" rowspan="<?php echo count($playersTanke); ?>"><img src="iconos/tankes.png"/></td>


                    <?php
                    if (count($playersTanke) >= 1) {
                        echo '<td class = "DocumentItem ' . $playersTanke[0]['clase'] . '">' . $playersTanke[0]['nick'] . '</td>';
                        foreach ($bosses as $b) {

                            $itemsLista = R::getAll('select items.*, bislist.Bis, bislist.dificultad from items join bislist on items.id = bislist.item where bislist.pj = :pj and items.bosses_id = :boss_id order by bislist.Bis desc, bislist.dificultad desc', [':boss_id' => $b['id'], ':pj' => $playersTanke[0]['id']]);

                            echo '<td class = "DocumentItem">';


                            foreach ($itemsLista as $item) {

                                if ($item['slot'] == 'Hacha 1 mano' || $item['slot'] == 'Hacha 2 manos') {
                                    $slot = 'Hacha ';
                                } else if ($item['slot'] == 'Espada de 1 mano' || $item['slot'] == 'Espada de 2 manos') {
                                    $slot = 'Espada ';
                                } else if ($item['slot'] == 'Maza de 1 mano' || $item['slot'] == 'Maza de 2 manos') {
                                    $slot = 'Maza ';
                                } else if ($item['slot'] == 'Escopeta') {
                                    $slot = 'Ballesta ';
                                } else {
                                    $slot = $item['slot'] . ' ';
                                }

                                $dificultad = sufijoItem($item);

                                if ($item['dificultad'] == 'H') {
                                    $link = $item['linkh'];
                                } else {
                                    $link = $item['linkhw'];
                                }

                                echo '<a href="http://es.wowhead.com/item=' . $link . '" rel="item-' . $link . '&domain=es" target="_blank"><img class="imgicono" src="iconos/' . $slot . $dificultad . '"/></a>';
                            }
                            echo '</td>';
                        }
                        echo '<td class = "DocumentItem ' . $playersTanke[0]['clase'] . '">' . $playersTanke[0]['nick'] . '</td>';
                        echo '</tr>';
                    }



                    for ($i = 1; $i < count($playersTanke); $i++) {
                        echo '<tr>';
                        echo '<td class = "DocumentItem ' . $playersTanke[$i]['clase'] . '">' . $playersTanke[$i]['nick'] . '</td>';
                        foreach ($bosses as $b) {

                            $itemsLista = R::getAll('select items.*, bislist.Bis, bislist.dificultad from items join bislist on items.id = bislist.item where bislist.pj = :pj and items.bosses_id = :boss_id order by bislist.Bis desc, bislist.dificultad desc', [ ':boss_id' => $b['id'], ':pj' => $playersTanke[$i]['id']]);

                            echo '<td class = "DocumentItem">';


                            foreach ($itemsLista as $item) {

                                if ($item['slot'] == 'Hacha 1 mano' || $item['slot'] == 'Hacha 2 manos') {
                                    $slot = 'Hacha ';
                                } else if ($item['slot'] == 'Espada de 1 mano' || $item['slot'] == 'Espada de 2 manos') {
                                    $slot = 'Espada ';
                                } else if ($item['slot'] == 'Maza de 1 mano' || $item['slot'] == 'Maza de 2 manos') {
                                    $slot = 'Maza ';
                                } else if ($item['slot'] == 'Escopeta') {
                                    $slot = 'Ballesta ';
                                } else {
                                    $slot = $item['slot'] . ' ';
                                }

                                $dificultad = sufijoItem($item);

                                if ($item['dificultad'] == 'H') {
                                    $link = $item['linkh'];
                                } else {
                                    $link = $item['linkhw'];
                                }

                                echo '<a href="http://es.wowhead.com/item=' . $link . '" rel="item-' . $link . '&domain=es" target="_blank"><img class="imgicono" src="iconos/' . $slot . $dificultad . '"/></a>';
                            }
                            echo '</td>';
                        }
                        echo '<td class = "DocumentItem ' . $playersTanke[$i]['clase'] . '">' . $playersTanke[$i]['nick'] . '</td>';

                        echo '</tr>';
                    }
                    /*
                      <td class = "DocumentItem">Player1</td>
                      <td class = "DocumentItem">Item1</td>
                      </tr>
                      <tr>
                      <td class = "DocumentItem">Player2</td>
                      <td class = "DocumentItem">Item2</td>
                      </tr> */
                    ?>
                <tr>
                    <td class="DocumentItemB tiporol" rowspan="<?php echo count($playersDPSMelee); ?>"><img src="iconos/dps.png"/></td>


                    <?php
                    if (count($playersDPSMelee) >= 1) {
                        echo '<td class = "DocumentItem ' . $playersDPSMelee[0]['clase'] . '">' . $playersDPSMelee[0]['nick'] . '</td>';
                        foreach ($bosses as $b) {

                            $itemsLista = R::getAll('select items.*, bislist.Bis, bislist.dificultad from items join bislist on items.id = bislist.item where bislist.pj = :pj and items.bosses_id = :boss_id order by bislist.Bis desc, bislist.dificultad desc', [':boss_id' => $b['id'], ':pj' => $playersDPSMelee[0]['id']]);

                            echo '<td class = "DocumentItem">';


                            foreach ($itemsLista as $item) {

                                if ($item['slot'] == 'Hacha 1 mano' || $item['slot'] == 'Hacha 2 manos') {
                                    $slot = 'Hacha ';
                                } else if ($item['slot'] == 'Espada de 1 mano' || $item['slot'] == 'Espada de 2 manos') {
                                    $slot = 'Espada ';
                                } else if ($item['slot'] == 'Maza de 1 mano' || $item['slot'] == 'Maza de 2 manos') {
                                    $slot = 'Maza ';
                                } else if ($item['slot'] == 'Escopeta') {
                                    $slot = 'Ballesta ';
                                } else {
                                    $slot = $item['slot'] . ' ';
                                }

                                $dificultad = sufijoItem($item);

                                if ($item['dificultad'] == 'H') {
                                    $link = $item['linkh'];
                                } else {
                                    $link = $item['linkhw'];
                                }

                                echo '<a href="http://es.wowhead.com/item=' . $link . '" rel="item-' . $link . '&domain=es" target="_blank"><img class="imgicono" src="iconos/' . $slot . $dificultad . '"/></a>';
                            }
                            echo '</td>';
                        }
                        echo '<td class = "DocumentItem ' . $playersDPSMelee[0]['clase'] . '">' . $playersDPSMelee[0]['nick'] . '</td>';
                        echo '</tr>';
                    }

                    for ($i = 1; $i < count($playersDPSMelee); $i++) {
                        echo '<tr>';
                        echo '<td class = "DocumentItem ' . $playersDPSMelee[$i]['clase'] . '">' . $playersDPSMelee[$i]['nick'] . '</td>';
                        foreach ($bosses as $b) {

                            $itemsLista = R::getAll('select items.*, bislist.Bis, bislist.dificultad from items join bislist on items.id = bislist.item where bislist.pj = :pj and items.bosses_id = :boss_id order by bislist.Bis desc, bislist.dificultad desc', [ ':boss_id' => $b['id'], ':pj' => $playersDPSMelee[$i]['id']]);

                            echo '<td class = "DocumentItem">';


                            foreach ($itemsLista as $item) {

                                if ($item['slot'] == 'Hacha 1 mano' || $item['slot'] == 'Hacha 2 manos') {
                                    $slot = 'Hacha ';
                                } else if ($item['slot'] == 'Espada de 1 mano' || $item['slot'] == 'Espada de 2 manos') {
                                    $slot = 'Espada ';
                                } else if ($item['slot'] == 'Maza de 1 mano' || $item['slot'] == 'Maza de 2 manos') {
                                    $slot = 'Maza ';
                                } else if ($item['slot'] == 'Escopeta') {
                                    $slot = 'Ballesta ';
                                } else {
                                    $slot = $item['slot'] . ' ';
                                }

                                $dificultad = sufijoItem($item);

                                if ($item['dificultad'] == 'H') {
                                    $link = $item['linkh'];
                                } else {
                                    $link = $item ['linkhw'];
                                }

                                echo '<a href="http://es.wowhead.com/item=' . $link . '" rel="item-' . $link . '&domain=es" target="_blank"><img class="imgicono" src="iconos/' . $slot . $dificultad . '"/></a>';
                            }
                            echo '</td>';
                        }
                        echo '<td class = "DocumentItem ' . $playersDPSMelee[$i]['clase'] . '">' . $playersDPSMelee[$i]['nick'] . '</td>';
                        echo '</tr>';
                    }
                    /*
                      <td class = "DocumentItem">Player1</td>
                      <td class = "DocumentItem">Item1</td>
                      </tr>
                      <tr>
                      <td class = "DocumentItem">Player2</td>
                      <td class = "DocumentItem">Item2</td>
                      </tr> */
                    ?>
                <tr>
                    <td class="DocumentItemB tiporol" rowspan="<?php echo count($playersHeal); ?>"><img src="iconos/heals.png"/></td>


                    <?php
                    if (count($playersHeal) >= 1) {
                        echo '<td class = "DocumentItem ' . $playersHeal[0]['clase'] . '">' . $playersHeal[0]['nick'] . '</td>';
                        foreach ($bosses as $b) {

                            $itemsLista = R::getAll('select items.*, bislist.Bis, bislist.dificultad from items join bislist on items.id = bislist.item where bislist.pj = :pj and items.bosses_id = :boss_id order by bislist.Bis desc, bislist.dificultad desc', [ ':boss_id' => $b['id'], ':pj' => $playersHeal[0]['id']]);

                            echo '<td class = "DocumentItem">';


                            foreach ($itemsLista as $item) {

                                if ($item['slot'] == 'Hacha 1 mano' || $item['slot'] == 'Hacha 2 manos') {
                                    $slot = 'Hacha ';
                                } else if ($item['slot'] == 'Espada de 1 mano' || $item['slot'] == 'Espada de 2 manos') {
                                    $slot = 'Espada ';
                                } else if ($item['slot'] == 'Maza de 1 mano' || $item['slot'] == 'Maza de 2 manos') {
                                    $slot = 'Maza ';
                                } else if ($item['slot'] == 'Escopeta') {
                                    $slot = 'Ballesta ';
                                } else {
                                    $slot = $item['slot'] . ' ';
                                }

                                $dificultad = sufijoItem($item);

                                if ($item['dificultad'] == 'H') {
                                    $link = $item['linkh'];
                                } else {
                                    $link = $item ['linkhw'];
                                }

                                echo '<a href="http://es.wowhead.com/item=' . $link . '" rel="item-' . $link . '&domain=es" target="_blank"><img class="imgicono" src="iconos/' . $slot . $dificultad . '"/></a>';
                            }

                            echo '</td>';
                        }
                        echo '<td class = "DocumentItem ' . $playersHeal[0]['clase'] . '">' . $playersHeal[0]['nick'] . '</td>';
                        echo '</tr>';
                    }

                    for ($i = 1; $i < count($playersHeal); $i ++) {
                        echo '<tr>';
                        echo '<td class = "DocumentItem ' . $playersHeal[$i]['clase'] . '">' . $playersHeal[$i]['nick'] . '</td>';
                        foreach ($bosses as $b) {

                            $itemsLista = R::getAll('select items.*, bislist.Bis, bislist.dificultad from items join bislist on items.id = bislist.item where bislist.pj = :pj and items.bosses_id = :boss_id order by bislist.Bis desc, bislist.dificultad desc', [ ':boss_id' => $b['id'], ':pj' => $playersHeal[$i]['id']]);

                            echo '<td class = "DocumentItem">';


                            foreach ($itemsLista as $item) {

                                if ($item['slot'] == 'Hacha 1 mano' || $item['slot'] == 'Hacha 2 manos') {
                                    $slot = 'Hacha ';
                                } else if ($item['slot'] == 'Espada de 1 mano' || $item['slot'] == 'Espada de 2 manos') {
                                    $slot = 'Espada ';
                                } else if ($item['slot'] == 'Maza de 1 mano' || $item['slot'] == 'Maza de 2 manos') {
                                    $slot = 'Maza ';
                                } else if ($item['slot'] == 'Escopeta') {
                                    $slot = 'Ballesta ';
                                } else {
                                    $slot = $item['slot'] . ' ';
                                }

                                $dificultad = sufijoItem($item);

                                if ($item['dificultad'] == 'H') {
                                    $link = $item['linkh'];
                                } else {
                                    $link = $item ['linkhw'];
                                }

                                echo '<a href="http://es.wowhead.com/item=' . $link . '" rel="item-' . $link . '&domain=es" target="_blank"><img class="imgicono" src="iconos/' . $slot . $dificultad . '"/></a>';
                            }
                            echo '</td>';
                        }
                        echo '<td class = "DocumentItem ' . $playersHeal[$i]['clase'] . '">' . $playersHeal[$i]['nick'] . '</td>';
                        echo '</tr>';
                    }
                    /*
                      <td class = "DocumentItem">Player1</td>
                      <td class = "DocumentItem">Item1</td>
                      </tr>
                      <tr>
                      <td cl ass = "DocumentItem">Player2</td>
                      <td class = "DocumentItem">Item2</td>
                      </tr> */
                    ?>
                <tr>
                    <td class="DocumentItemB tiporol" rowspan="<?php echo count($playersDPSCaster); ?>"><img src="iconos/dps.png"/></td>


                    <?php
                    if (count($playersDPSCaster) >= 1) {
                        echo '<td class = "DocumentItem ' . $playersDPSCaster[0]['clase'] . '">' . $playersDPSCaster[0]['nick'] . '</td>';
                        foreach ($bosses as $b) {

                            $itemsLista = R::getAll('select items.*, bislist.Bis, bislist.dificultad from items join bislist on items.id = bislist.item where bislist.pj = :pj and items.bosses_id = :boss_id order by bislist.Bis desc, bislist.dificultad desc', [ ':boss_id' => $b['id'], ':pj' => $playersDPSCaster[0]['id']]);

                            echo '<td class = "DocumentItem">';


                            foreach ($itemsLista as $item) {

                                if ($item['slot'] == 'Hacha 1 mano' || $item['slot'] == 'Hacha 2 manos') {
                                    $slot = 'Hacha ';
                                } else if ($item['slot'] == 'Espada de 1 mano' || $item['slot'] == 'Espada de 2 manos') {
                                    $slot = 'Espada ';
                                } else if ($item['slot'] == 'Maza de 1 mano' || $item['slot'] == 'Maza de 2 manos') {
                                    $slot = 'Maza ';
                                } else if ($item['slot'] == 'Escopeta') {
                                    $slot = 'Ballesta ';
                                } else {
                                    $slot = $item['slot'] . ' ';
                                }

                                $dificultad = sufijoItem($item);

                                if ($item['dificultad'] == 'H') {
                                    $link = $item['linkh'];
                                } else {
                                    $link = $item ['linkhw'];
                                }

                                echo '<a href="http://es.wowhead.com/item=' . $link . '" rel="item-' . $link . '&domain=es" target="_blank" ><img class="imgicono" src="iconos/' . $slot . $dificultad . '"/></a>';
                            }

                            echo ' </td>';
                        }
                        echo '<td class = "DocumentItem ' . $playersDPSCaster[0]['clase'] . '">' . $playersDPSCaster[0]['nick'] . '</td>';
                        echo '</tr>';
                    }
                    for ($i = 1; $i < count($playersDPSCaster); $i++) {
                        echo '<tr>';
                        echo '<td class = "DocumentItem ' . $playersDPSCaster[$i]['clase'] . '">' . $playersDPSCaster[$i]['nick'] . '</td>';
                        foreach ($bosses as $b) {

                            $itemsLista = R::getAll('select items.*, bislist.Bis, bislist.dificultad from items join bislist on items.id = bislist.item where bislist.pj = :pj and items.bosses_id = :boss_id order by bislist.Bis desc, bislist.dificultad desc', [ ':boss_id' => $b['id'], ':pj' => $playersDPSCaster[$i]['id']]);

                            echo '<td class = "DocumentItem">';


                            foreach ($itemsLista as $item) {

                                if ($item['slot'] == 'Hacha 1 mano' || $item['slot'] == 'Hacha 2 manos') {
                                    $slot = 'Hacha ';
                                } else if ($item['slot'] == 'Espada de 1 mano' || $item['slot'] == 'Espada de 2 manos') {
                                    $slot = 'Espada ';
                                } else if ($item['slot'] == 'Maza de 1 mano' || $item['slot'] == 'Maza de 2 manos') {
                                    $slot = 'Maza ';
                                } else if ($item['slot'] == 'Escopeta') {
                                    $slot = 'Ballesta ';
                                } else {
                                    $slot = $item['slot'] . ' ';
                                }

                                $dificultad = sufijoItem($item);

                                if ($item['dificultad'] == 'H') {
                                    $link = $item['linkh'];
                                } else {
                                    $link = $item ['linkhw'];
                                }

                                echo '<a href="http://es.wowhead.com/item=' . $link . '" rel="item-' . $link . '&domain=es" target="_blank"><img class="imgicono" src="iconos/' . $slot . $dificultad . '"/></a>';
                            }
                            echo '</td>';
                        }
                        echo '<td class = "DocumentItem ' . $playersDPSCaster[$i]['clase'] . '">' . $playersDPSCaster[$i]['nick'] . '</td>';
                        echo '</tr>';
                    }

                    /*
                      <td class = "DocumentItem">Player1</td>
                      <td class = "DocumentItem">Item1</td>
                      </tr>
                      <tr>
                      <td class = "DocumentItem">Player2</td>
                      <td class = "DocumentItem">Item2</td>
                      </tr> */
                    ?>

                <tr>
                    <th class="DocumentItemE2 tipo2"></th>
                    <th class="DocumentItemE tipoplayer2"></th>
                    <?php
                    foreach ($bosses as $b) {
                        echo "<th class='DocumentItemE'><a href='editarBisList.php?id=" . $b['id'] . "'>" . $b['nombre'] . "</a></th>";
                    }
                    ?>
                    <th class="DocumentItemE tipoplayer4"></th>
                </tr>
            </table>
        </div>
        <script type="text/javascript">

            var totalWidth = $('.DocumentItemC').length * ($('.DocumentItemC').width() + 2) + $('.DocumentItemD').width();
            $('body').css('width', totalWidth + 'px');
            $('.imgicono').tooltip();
        </script>
    </div>




    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->


    <?php
    include 'pie.php';
    ?>